//
//  WmcHomeCameraPermissionTipView.swift
//  YPWatermarkCamera
//
//  Created by Json on 2023/10/19.
//  相机权限(未开启)提示View

import UIKit

class WmcHomeCameraPermissionTipView: WmcBaseView {

    private lazy var stackView: UIStackView = {
        let stackV = UIStackView()
        stackV.axis = .vertical
        stackV.spacing = 15.0.wmc_autoHor
        stackV.distribution = .fill
        stackV.alignment = .center
        return stackV
    }()
    
    private lazy var msgLabel: UILabel = {
        let label = UILabel()
        label.font = 16.wmc_font
        label.textColor = UIColor.wmc_white_FFFFFF
        label.textAlignment = .center
        label.text = "开启相机权限,即可正常拍摄"
        label.numberOfLines = 0
        return label
    }()
    
    private lazy var button: UIButton = {
        let button = UIButton()
        button.backgroundColor = UIColor.wmc_mainTheme
        button.setTitle("去开启", for: .normal)
        button.setTitleColor(UIColor.wmc_white_FFFFFF, for: .normal)
        button.titleLabel?.font = 15.wmc_font
        button.layer.cornerRadius = 4.0
        button.clipsToBounds = true
        return button
    }()
    
    
    override func makeUI() {
        super.makeUI()
        backgroundColor = UIColor.clear
        addSubview(stackView)
        stackView.snp.makeConstraints { make in
            make.edges.equalToSuperview()
        }
        stackView.addArrangedSubview(msgLabel)
        stackView.addArrangedSubview(button)
        button.snp.makeConstraints { make in
            make.width.equalTo(80.0.wmc_autoHor)
            make.height.equalTo(35.0.wmc_autoHor)
        }
    }
    
    override func bindViewAction() {
        super.bindViewAction()
        button.rx.tap.subscribe(onNext: {
            [weak self] in
            guard let self = self else { return }
            WmcAuthorizedManager.openSetting()
        }).disposed(by: rx.disposeBag)
    }

}
